Book-O-Rama Search Results

"; $query = "select * from books.books where ".$searchtype." like '%".$searchterm."%'"; //SQL query uses 'like' to improve chance of a hit $result = mysql_query($query, $db); //execute the SQL query - returned table is in variable $result // note that W&T has this backwards!: $result = mysql_query($db, $query); $num_results = mysql_num_rows($result); echo "

Number of books found: ".$num_results."

"; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_assoc($result); //returns a row of the result set as a 1-dim array indexed by attribute names echo "

".($i+1).". Title: "; echo $row['title']; echo "
Author: "; echo $row['author']; echo "
ISBN: "; echo $row['isbn']; echo "
Price: "; echo $row['price']; echo "

"; } mysql_free_result($result); //free up the result set mysql_close($db); //close the database connection - lets other users in ?>